﻿<?php 
	session_start();
	?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>土塘中学成绩查询系统</title>
<meta name="author" content="Codrops" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"/>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="shortcut icon" href="../favicon.ico">
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script src="js/modernizr.custom.63321.js"></script>
<!--[if lte IE 7]><style>.main{display:none;} .support-note .note-ie{display:block;}</style>
<![endif]-->
<style>
@import url(http://fonts.googleapis.com/css?family=Montserrat:400,700|Handlee);
body {
		background: #eedfcc url(images/bg3.jpg) no-repeat center top;
		-webkit-background-size: cover;
		-moz-background-size: cover;
		background-size: cover;
	
}
.container > header h1,
.container > header h2 {
color: #fff;
text-shadow: 0 1px 1px rgba(0,0,0,0.5);
}
</style>
</head>
<body>
<div class="container">
	
<header>
	
	

<nav class="codrops-demos">
<a href="http://www.tutangzx.cn">返回学校网站</a>
<a href="#" title="请输入用户名密码登陆，学生用学号登陆，老师用学校发放的账号登录，初始密码请咨询教务处。如有问题请联系管理员！">帮助</a>
<a href="#" title="请联系教务处咨询使用问题！">联系管理员</a>
<a href="#" title="土塘中学成绩管理系统是由土塘中学独立开发完成的一套成绩管理系统，版权归土塘中学所有">关于成绩管理系统</a>

				</nav>

				<div class="support-note">
						<span class="note-ie">对不起，您使用的浏览器过旧，无法浏览本页面，建议您使用IE7以上或者火狐浏览器.</span>
				</div>

</header>
	
			<section class="main">
			<form id="logform" name="logform" class="form-5 clearfix" method="post">
			<p>
			<input type="text" id="login" name="login" placeholder="用户名">
					<input type="password" name="password" id="password" placeholder="密码">
							</p>
							<button type="submit" name="submit" onclick="return check()">
				    	<i class="icon-arrow-right"></i>
				    	<span>登录</span>
				    	</button>
				    			</form></section>
				    				
				    			</div>
				    			<!-- jQuery if needed -->
				    		
				    					<script type="text/javascript" src="js/jquery.placeholder.min.js"></script>
				    					<script type="text/javascript">
		$(function(){
			$('input, textarea').placeholder();
			
		});
		</script>
		<script type="text/javascript">
		 $(function() {
			 $( document ).tooltip();
			 });
		 </script>
<script type="text/javascript">
function check()
{
	if($("input#login").val()=="")
	{alert("请填写用户名!");return false;}
	if($("input#password").val()=="")
	{alert("请填写密码");return false;}
	return true;
	
}
</script>
<p class="footer"><b>Copyright All Reserved by <a href="http://www.tutangzx.cn">tutangzx.cn</a> @2013</b>	</p>
		</body>
			</html>
			
			<?php
		
			include 'conn.php';
			include 'common.php';
			
			/*
			if(!empty($_SESSION))
			{
				if($_SESSION['user_category']==1)
					echo 	"<script language=JavaScript>window.location='student.php';</script>";
				if($_SESSION['user_category']==2)
					echo "<script language=JavaScript>window.location='teacher.php';</script>";
				if($_SESSION['user_category']==3)
					echo "<script language=JavaScript>window.location='admin.php';</script>";
			}
			*/
			$username=getpost('login');
			$passwd=getpost('password');
			//echo $username;
			//echo $passwd;
			if($username and $passwd)
			{
				$exe="select * from users where username='$username'";
				//echo "<script language=JavaScript>alert($exe);</script>";
				$rs=mysql_query($exe);
				//echo $exe;
				$row=mysql_fetch_array($rs);
				if($row['username']) {
					if($row['passwd']==md5($passwd)) {
                       if($row['realname'])
                       	$_SESSION['username']=$row['realname'];
                       else
				     	$_SESSION['username']=$row['username'];
				     	$_SESSION['userid']=$row['id'];
						//else $_SESSION['username']=$row['username'];
						//echo "<script language=JavaScript>alert(".$_SESSION['username']." );</script>";
						//echo "<script language=JavaScript>alert('登录成功');</script>";
						if($row['user_category']==1)
						{
							$_SESSION['user_category']=1;
							echo 	"<script language=JavaScript>window.location='student.php';</script>"		;
					
						}
						if($row['user_category']==2)
						{
							$_SESSION['user_category']=2;
							echo "<script language=JavaScript>window.location='teacher.php';</script>";
						
						}
							
						if($row['user_category']==3)
						{
							$_SESSION['user_category']=3;
							echo "<script language=JavaScript>window.location='admin.php';</script>";
						
						}
} 
					else 
					{
						echo "<script language=JavaScript>alert('登录失败');</script>";
					}		
				}
				else 
				{
					echo "<script language=JavaScript>alert('登录失败');</script>";
				}
			}
			?>
			